home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 03 - 1987 / 03.11 Nov 87 / C string library / PStrLib Source / org_PStrDraw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-09  |  1014 b   |  36 lines  |  [TEXT/KAHL]

  1. /*    FILE:  PStrDraw.c
  2.     Draws 1 to 10 Pascal strings at specified locations in the 
  3.     current GrafPort.  It Offers auto-centering and New-Line modes. */
  4. #include    "PStrLib.h"
  5.  
  6. PStrDraw(count, s, h, v)
  7. int        count;    /* number of { s, h, v} sets to follow */
  8. char    *s;        /* a pascal string to draw */
  9. int        h;        /* horizontal position */
  10. int        v;        /* vertical position */
  11. {    
  12.     register    char    *argPtr = (char *)&count;
  13.     register    char    *sp;
  14.     register    Rect    *rp = &thePort->portRect;
  15.     register    int        x, y, lineHeight = 1.5 * thePort->txSize;
  16.     static        int        old_x = 0, old_y = 0;
  17.     
  18.     if (count > 0) {
  19.         while (--count >= 0) {
  20.             sp = *(char **)(argPtr += 2);
  21.             x = *(int *)(argPtr += 4);
  22.             y = *(int *)(argPtr += 2);
  23.             if (x >= 0)    
  24.                 old_x = x;
  25.             else if (x != CUR)    /* Auto-Center Mode? */
  26.                 old_x = (rp->right - rp->left - StringWidth(sp)) / 2;
  27.             if (y >= 0)
  28.                 old_y = y;
  29.             else if (y != CUR)    /* New-Line Mode? */
  30.                 old_y += -y * lineHeight;
  31.             MoveTo(old_x, old_y);
  32.             DrawString(sp);
  33.             old_x += StringWidth(sp);
  34.         }
  35.     }
  36. }